import { defineStore } from 'pinia'
import { createCommonGetters, createCommonActions } from "../helper"
import $api from '@/api'

export const useQuestionStore = defineStore('question', {
  state: () => ({
    // 存储 API 请求参数和结果
    api: {
      //获取问题列表接口
      questionList: {
        loading: false,
        params: {
          "page": 1,
          "size": 20,
          "offset": 0,
          "province": "",
          "year": "",
          "grade": "",
          "subject": "",
          "typeId": ""
        },
      },

    },
  }),
  getters: {
    ...createCommonGetters
  },
  actions: {
    ...createCommonActions(),
    // 获取题目列表数据
    async fetchQuestionList(params = {}) {
      const res = await $api.question.list({ ...params })
      return res
    },
    //重置
    resetQuestion() {
      this.$reset()
    },
  },
  persist: true

})
